package javacode.chapter04.exer;

import java.util.Scanner;

public class Exercise02 {
    public static void main(String[] args) {
        // 编程实现加、减、乘、除的简单计算器
        Scanner scanner = new Scanner(System.in);
        double a, b, result;
        String op;
        System.out.print("请输入两个数进行运算（以空格分隔）：");
        a = scanner.nextDouble();
        b = scanner.nextDouble();
        System.out.print("请输入要进行的运算操作（+或-或*或/）:");
        op = scanner.next();
        switch (op) {
            case "+":
                result = a + b;
                break;
            case "-":
                result = a - b;
                break;
            case "*":
                result = a * b;
                break;
            case "/":
                result = a / b;
                break;
            default:
                result = -1;
        }
        System.out.println("计算的最终结果是：" + result);
    }
}
